﻿using Ldt.DataEngine.RuleAssemble;
using LdtJudge.DataEngine.Data;
using System.Collections.Generic;
using System.Linq;

namespace LdtDataEngin.ModuleDetail.AnalysisModule.PersonnelAnalysis
{
    /// <summary>
    /// 获取当事人类型
    /// </summary>
    public class GetPartiesType
    {
        /// <summary>
        /// 利用信息单元提取当事人类型
        /// </summary>
        /// <param name="orgtext">原文，来源机器学习</param>
        /// <returns></returns>
        public static string Extract(string orgtext)
        {
            SqlSysCommon sqlSyscom = new SqlSysCommon("Ldt_JudgeDocSystem");

            var re = RuleParseClass.GetParseRegCodeValueManyOrg("GetParticipantTypeID", new List<string>() { orgtext });
            string ptype =  re.Count()==0 ? string.Empty : re.First();
            if (!string.IsNullOrEmpty(ptype))
            {
                // 将名称转字典
                ptype = sqlSyscom.GetDictionaryId("ParticipantTypeID", ptype)?.First().AM_Code;
            }
            return ptype;
        }
    }
}
